package com.whf.android.jar.base.mvp;


import android.content.Context;

import androidx.annotation.NonNull;

import com.whf.android.jar.base.delegate.BaseDelegate;

/**
 * MVP类
 *
 * @author qf
 * @version 1.0.24
 **/
public abstract class BaseMvpDelegate<M extends IModel, V extends IView, P extends BasePresenter<M, V>>
        extends BaseDelegate implements BaseMvp<M, V, P> {

    protected P presenter;

    @Override
    public void onAttach(@NonNull Context context) {
        super.onAttach(context);
        presenter = createPresenter();
        if (presenter != null) {
            presenter.registerModel(createModel());
            presenter.registerView(createView());
        }
    }


    @Override
    public void onDetach() {
        super.onDetach();
        if (presenter != null) {
            presenter.destroy();
        }
    }
}
